<?php
ob_start();
?>
<?php
include ('encabezado.php');
?>
<form action="" method="post">
<input type="hidden" value="true" name="submitted">
<br><br>
<table align="center" border="2">
<tr>

<td align="center">
<h2>Create group <br></h2>
Name: <br>
<input type="text" name="nombreg"><br><br>
<input type="submit" value="Create group"><br>
<?php
if (isset($_POST['submitted']))
{
if (!empty($_POST['nombreg']) == true)
{
 $conexion = mysql_connect("$ip", "$userdb", "$passworddb");
 mysql_select_db("$db", $conexion);
 $nombreg = strtoupper($_POST['nombreg']);
 $q= "SELECT * FROM `Groups` WHERE Name = '$nombreg'";
 $h= "INSERT INTO `Groups` (Name) VALUE ('$nombreg')";
 $result=mysql_query($q, $conexion);
while ($registro = mysql_fetch_array($result))
    {
      $res=$registro['Name'];
    }
  if (!isset($res))
  {
	mysql_query($h, $conexion);
	echo '<br> Inserted.';
  }
  else
  {
   echo '<br> Not inserted.';
  }
}else
{
 echo '<br> Fill all fields.';
}
}
?>
</td></tr>
</table>
<?php
include ('pie.php');
?>
<?php
ob_end_flush();
?>